<template>
  <ul class="songlist">
    <li v-for="(item, index) in songs" :key="index">
      <i v-show="showNum" :class="['num', { red: index < 3 }]">{{
        (index + 1) | addZero
      }}</i>
      <div class="left">
        <h5>{{ item.name }}</h5>
        <p>
          <i v-show="item.song.privilege.playMaxbr == 999000" class="sq"></i
          >{{ item.song.artists[0].name }} - {{ item.name }}
        </p>
      </div>
      <div class="right">
        <img
          class="playBtn"
          @click="$emit('play', item)"
          src="../assets/play.png"
        />
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  // hot下半部分
  name: "SongList",
  props: {
    songs: Array,
    showNum: {
      type: Boolean,
      default: false,
    },
  },
  filters: {
    addZero(val) {
      return val < 10 ? "0" + val : val;
    },
  },
};
</script>

<style lang="less" scoped>
.songlist {
  padding-left: 10px;
  li {
    display: flex;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 6px 0px;
    i.num {
      display: inline-block;
      line-height: 43px;
      font-style: normal;
      width: 40px;
      font-size: 17px;
    }
    i.red {
      color: #df3436;
    }
    .left {
      flex: 1;
      overflow: hidden;
      h5 {
        font-size: 17px;
        font-weight: 400;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: 100%;
      }
      p {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        i.sq {
          display: inline-block;
          width: 12px;
          height: 8px;
          margin-right: 4px;
          background: url("../assets/small.png") no-repeat;
          background-size: 166px 97px;
        }
      }
    }
    .right {
      width: 25px;
      height: 25px;
      padding: 0px 14px;
      display: flex;

      .playBtn {
        display: inline-block;
        width: 25px;
        height: 25px;
        margin-top: 10px;
      }
    }
  }
}
</style>